Fork of Chiri for Astro for my blog
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 796ce0a584985e2cc4e9997875b2267944315fed 54 lines 1.6 kB view raw
1import { getCollection, type CollectionEntry } from 'astro:content' 2import { OGImageRoute } from 'astro-og-canvas' 3import { themeConfig } from '../../config' 4 5export const prerender = true 6 7const collectionEntries = await getCollection('posts') 8 9// Map the array of content collection entries to create an object. 10// Converts [{ id: 'post.md', data: { title: 'Example', pubDate: Date } }] 11// to { 'post.md': { title: 'Example', pubDate: Date } } 12const pages = Object.fromEntries( 13 collectionEntries.map((entry: CollectionEntry<'posts'>) => [ 14 entry.id.replace(/\.(md|mdx)$/, ''), 15 entry.data 16 ]) 17) 18 19export const { getStaticPaths, GET } = await OGImageRoute({ 20 param: 'route', 21 pages, 22 getImageOptions: (_path: string, page: CollectionEntry<'posts'>['data']) => ({ 23 title: page.title, 24 description: themeConfig.site.title, 25 logo: { 26 path: 'public/og/og-logo.png', 27 size: [80, 80] 28 }, 29 bgGradient: [[255, 255, 255]], 30 bgImage: { 31 path: 'public/og/og-bg.png', 32 fit: 'fill' 33 }, 34 padding: 64, 35 font: { 36 title: { 37 color: [28, 28, 28], 38 size: 68, 39 weight: 'SemiBold', 40 families: ['PingFang SC'] 41 }, 42 description: { 43 color: [180, 180, 180], 44 size: 40, 45 weight: 'Medium', 46 families: ['PingFang SC'] 47 } 48 }, 49 fonts: [ 50 'https://cdn.jsdelivr.net/npm/font-pingfang-sc-font-weight-improved@latest/PingFangSC-Medium.woff2', 51 'https://cdn.jsdelivr.net/npm/font-pingfang-sc-font-weight-improved@latest/PingFangSC-Semibold.woff2' 52 ] 53 }) 54})